package metadatabrowser;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import com.swtdesigner.SWTResourceManager;

public class SchemaRefactoringViewer extends Dialog {
	private Text text;
	private String sqlCode;
	/**
	 * Create the dialog.
	 * @param parentShell
	 */
	public SchemaRefactoringViewer(Shell parentShell) {
		super(parentShell);
		setShellStyle(SWT.RESIZE | SWT.TITLE);
	}
	
	
	@Override
	protected void configureShell(Shell newShell) {
		// TODO Auto-generated method stub
		super.configureShell(newShell);
		newShell.setText("Schema Refactoring");
	}
	
	
	public String getRefactoringSql(){
		return sqlCode;
	}
	public void setRefactoringSql(String refactoringSql){
		sqlCode = refactoringSql;
		if(text != null){
			text.setText(refactoringSql);
		}
		
	}

	/**
	 * Create contents of the dialog.
	 * @param parent
	 */
	@Override
	protected Control createDialogArea(Composite parent) {
		Composite container = (Composite) super.createDialogArea(parent);
		container.setLayout(new FillLayout(SWT.HORIZONTAL));
		
		text = new Text(container, SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL);
		text.setFont(SWTResourceManager.getFont("Monospace", 9, SWT.NORMAL));
		text.setEditable(false);
		text.setText(sqlCode);
		return container;
	}

	/**
	 * Create contents of the button bar.
	 * @param parent
	 */
	@Override
	protected void createButtonsForButtonBar(Composite parent) {
		createButton(parent, IDialogConstants.CLOSE_ID, "Close",
				true);
	}

	/**
	 * Return the initial size of the dialog.
	 */
	@Override
	protected Point getInitialSize() {
		return new Point(496, 350);
	}

}
